<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>修改数据</button>
  <input type="text"><br>
  <output></output>
  <script>
    const input = document.querySelector('input');
    const output = document.querySelector('output');
    const btn = document.querySelector('button');

    let obj = {
      value: null
    }
    input.addEventListener('input', function () {
      obj.value = this.value
    }, false)

    btn.addEventListener('click', function () {
      obj.value = 'hello world';
    }, false)

    function setValue(val) {
      output.innerText = val
      input.value = val
    }

    Object.defineProperty(obj, 'value', {
      set(val) {
        setValue(val);
      }
    })
  </script>
</body>

</html>